cc.Class({
    extends: cc.Component,

    properties: {
        winAudio: {
            default: null,
            type: cc.AudioClip
        },

        loseAudio: {
            default: null,
            type: cc.AudioClip
        },

        cardAudio: {
            default: null,
            type: cc.AudioClip
        },

        buttonAudio: {
            default: null,
            type: cc.AudioClip
        },

        chipsAudio: {
            default: null,
            type: cc.AudioClip
        },
        diAudio: {
            default: null,
            type: cc.AudioClip
        },
        clearAudio: {
            default: null,
            type: cc.AudioClip
        },

        stopBetAudio: {
            default: null,
            type: cc.AudioClip
        },
        bgm: {
            default: null,
            type: cc.AudioClip
        },
        music:false,
        effect:true,

    },
    onLoad(){
       this. musicSetting(this.music);
       this. effectSetting(this.effect)
    },

    playMusic: function() {
        cc.audioEngine.playMusic( this.bgm, true );
    },

    pauseMusic: function() {
        cc.audioEngine.pauseMusic();
    },

    resumeMusic: function() {
        cc.audioEngine.resumeMusic();
    },
     

    musicSetting(music){
        this.music=music;
        if (this.music) {
            this.resumeMusic();
        } else {
            this.pauseMusic();
        }

    },
    effectSetting(effect){
        this.effect=effect;
    },
   

    _playSFX: function(clip) {
        if (this.effect) {
            cc.audioEngine.playEffect( clip, false );
        }
      
    },

    playWin: function() {
        this._playSFX(this.winAudio);
    },

    playLose: function() {
        this._playSFX(this.loseAudio);
    },

    playCard: function() {
        this._playSFX(this.cardAudio);
    },

    playChips: function() {
        this._playSFX(this.chipsAudio);
    },

    playButton: function() {
        this._playSFX(this.buttonAudio);
    } , 
    playDi: function() {
        this._playSFX(this.diAudio);
    },
    playStopBet(){
        this._playSFX(this.stopBetAudio);
    },
    playReturnBet(){
        this._playSFX(this.clearAudio);
    }

});
